package com.ruoyi.business.service.impl;

import java.util.List;

import com.ruoyi.business.domain.TPotentialCustomer;
import com.ruoyi.business.service.ITPotentialCustomerService;
import com.ruoyi.common.utils.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.business.mapper.TFollowUpRecordMapper;
import com.ruoyi.business.domain.TFollowUpRecord;
import com.ruoyi.business.service.ITFollowUpRecordService;
import com.ruoyi.common.core.text.Convert;

/**
 * 跟进记录Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-07-26
 */
@Service
public class TFollowUpRecordServiceImpl implements ITFollowUpRecordService 
{
    @Autowired
    private TFollowUpRecordMapper tFollowUpRecordMapper;

    /**
     * 查询跟进记录
     * 
     * @param id 跟进记录ID
     * @return 跟进记录
     */
    @Override
    public TFollowUpRecord selectTFollowUpRecordById(Long id)
    {
        return tFollowUpRecordMapper.selectTFollowUpRecordById(id);
    }

    /**
     * 查询跟进记录列表
     * 
     * @param tFollowUpRecord 跟进记录
     * @return 跟进记录
     */
    @Override
    public List<TFollowUpRecord> selectTFollowUpRecordList(TFollowUpRecord tFollowUpRecord)
    {
        return tFollowUpRecordMapper.selectTFollowUpRecordList(tFollowUpRecord);
    }

    /**
     * 新增跟进记录
     * 
     * @param tFollowUpRecord 跟进记录
     * @return 结果
     */
    @Override
    public int insertTFollowUpRecord(TFollowUpRecord tFollowUpRecord)
    {

        return tFollowUpRecordMapper.insertTFollowUpRecord(tFollowUpRecord);
    }


    @Autowired
    private ITPotentialCustomerService potentialCustomerService;
    /**
     * 修改跟进记录
     * 
     * @param tFollowUpRecord 跟进记录
     * @return 结果
     */

    @Override
    public int updateTFollowUpRecord(TFollowUpRecord tFollowUpRecord)
    {
        TPotentialCustomer tp = new TPotentialCustomer();
        tp.setId(tFollowUpRecord.getId());

        tp.setLastFollowUpTime(tFollowUpRecord.getFollowUpTime());
        potentialCustomerService.updata(tp);
        return tFollowUpRecordMapper.insertTFollowUpRecord(tFollowUpRecord);
    }

    /**
     * 删除跟进记录对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteTFollowUpRecordByIds(String ids)
    {
        return tFollowUpRecordMapper.deleteTFollowUpRecordByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除跟进记录信息
     * 
     * @param id 跟进记录ID
     * @return 结果
     */
    @Override
    public int deleteTFollowUpRecordById(Long id)
    {
        return tFollowUpRecordMapper.deleteTFollowUpRecordById(id);
    }

    @Override
    public List<TFollowUpRecord> selectCustomer(String id) {
        return  tFollowUpRecordMapper.selectCustomer(id);

    }

    @Override
    public int deleteById(Long id) {

        return tFollowUpRecordMapper.deleteById(id);

    }
}
